﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: Propietario			*/
/* País: Colombia, Bogotá			*/

#endregion

#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ESF.General.MVP;
using ESF.SSO.Core.Entities.BasicReferences;
using ESF.SSO.Core.BusinessLogic;
using ESF.SSO.Core.Entities;
using ESF.General.Entity;

#endregion 


namespace ESF.SSO.Presenter.Client
{
	public class RecoverPasswordPresenter : BasePresenter<IRecoverPasswordViewer>
	{
		#region Constructor
		
		public RecoverPasswordPresenter (IRecoverPasswordViewer pViewer) : base (pViewer) {}
		
		#endregion
		
	
		#region Funciones

		public override void Clear()
		{
			ClearError ();
			
			_Viewer.UserSecurityAnswer = string.Empty;
			_Viewer.UserEmail = string.Empty;
			_Viewer.UserSecurityQuestionID = null;
		}
		
		
		public override void Load ()
		{
		}
		
		
		public void RecoverPassword ()
		{
			try
			{
				CtrlUser.RecoverPassword (
					new User ()
					{
						Email = _Viewer.UserEmail,
						SecurityQuestion = new BasicReference () { ID = _Viewer.UserSecurityQuestionID },
						SecurityQuestionAnswer = _Viewer.UserSecurityAnswer
					});
					 
				_Viewer.frmInfoMsg = "Verifique en su correo electrónico por la recordación de su contraseña";
				
				Clear ();
			}
			catch (Exception pEx)
			{
				LogError (pEx);
			}
		}
		
		#endregion
	}
}
